bandcamp-dl
===========

A configuration for 'youtube-dl' for organized downloading from
 bandcamp.com


### Requirements for GNU/Linux:
 * python3
 * youtube-dl

### GNU/Linux quick start:
1. install python3 and youtube-dl with your package manager
2. invoke as:
> $ ./bandcamp-dl.py "$BANDCAMPURL"


### Requirements for windows:
 * [Python3](https://www.python.org/downloads/release/python-343/)
 * [youtube-dl](https://rg3.github.io/youtube-dl/download.html)
 * [Visual C++ 2008](http://www.microsoft.com/en-us/download/details.aspx?id=11895)
 >  if you get error message "system cannot execute specified program"

### Windows quick start:
1. install python
2. [download this repository as a zip](https://notabug.org/mya/bandcamp-dl/archive/master.zip)
3. extract the zip
4. download youtube-dl.exe from https://rg3.github.io/youtube-dl/download.html
5. put youtube-dl.exe in the folder where bandcamp-dl.py is located
6. run launch.bat
7. paste a bandcamp link into the dialog box
> bandcamp-dl.py is a command line program, but with launch.bat and
> input.vbs you can tell it to download a url without having to deal
> with the command prompt.



How this works:

 bandcamp-dl is used to download albums from bandcamp.com while also
  creating an organized data structure for a given album.

 Let's say I want to download all the tracks on a bandcamp album
  page. We can do this with

 $ youtube-dl http://example.bandcamp.com/album/example-album

 However what this does is just download all the mp3s to the current
  directory, neglecting the track numbers. If we run this again with a
  different album then things become extra messy. This is fine if you
  are ok with having one folder full of miscellaneous tracks, but I
  personally prefer a bit more structure. You can of coarse manually
  create a new folder, name it to the name of the album, make it your
  current directory of your shell, then invoke youtube-dl. This atleast
  keep albums seperate, but is also a chore if you wanted to download
  all the albums on an uploader's main page.

 The point of this script is to help youtube-dl do things "right" when
  downloading from bandcamp. If given a link to an album, it will
  create a folder for the bandcamp uploader, then another folder
  inside of this named after the artist and album. then it will
  download all tracks for this particular album to that folder. the
  tracks will be auto-numbered to preserve the artist's original
  arrangement intentions.

 Example:
 $ bandcamp-dl.py http://hardcorps.bandcamp.com/album/radio-sessions
  would create:
  DLDIR/hardcorps.bandcamp.com/Hard Corps - Radio Sessions/01 - Metal & Flesh - XXXXXXXXXX.mp3
  etc...

 By default 'DLDIR' is the current directory where you ran this script.
  The XXXXXXXXXX part is just a place holder for this example, it is a
  recording of where the track actually came from.

 Besides single album downloads, bandcamp-dl is also designed to support
  downloading full collections of an uploader.

 Example:
 $ bandcamp-dl.py http://telefuturenow.bandcamp.com/
 or
 $ bandcamp-dl.py http://telefuturenow.bandcamp.com/music
 or
 $ bandcamp-dl.py http://telefuturenow.bandcamp.com/music/
 are all acceptable. Each link to an album will be processed just like
 the first example.

 For now a config file is generated in the current directory when first
  run. you can edit this to define the location of the DLDIR or the
  youtube-dl binary. more options will come later.

 By default bandcamp-dl will exit if youtube-dl runs into an error. This
  is done becasue if you dont exit, youtube-dl will incorrectly number
  tracks if it can get some but not all. Also if you download a bunch of
  albums, it will become tedious to verify everything went ok. this can
  be turned off (as in ignore errors, just get mp3s at all costs) with
  the '--ignore-errors' switch

 $ 


 NOT IMPLEMENTED YET:
 You can change the DLDIR with the -D or --download-dir flag:
 $ bandcamp-dl.py http://hardcorps.bandcamp.com/album/radio-sessions -D /mnt/usb/music/webrips/bandcamp
 $ bandcamp-dl.py http://hardcorps.bandcamp.com/album/radio-sessions --download-dir /mnt/usb/music/webrips/bandcamp

 NOT IMPLEMENTED YET:
 Along with command line flags, bandcamp-dl will also check its current
  directory for a file named 'bcdl.cfg'. You can use the -G flag to
  generate a new config file if one doesn't already exist. You can also
  specify a config file in a different location with the -C or --config
  flag:
 $ bandcamp-dl.py http://hardcorps.bandcamp.com/album/radio-sessions -C /path/to/bcdl.cfg
 $ bandcamp-dl.py http://hardcorps.bandcamp.com/album/radio-sessions --config /path/to/bcdl.cfg

 NOT IMPLEMENTED YET:
 Normally bandcamp-dl will quit before doing anything if youtube-dl is
  not found. If you want to still run this script without youtube-dl
  present use the -Y flag.






Notes:

*  when artist name and album/track name are scraped from the html page
    there can be some characters that cause problems, for these problem
    characters we translate them to '\_', for now all illegal characters
    from window are translated to '\_' which are < > : " / \ | ? *

*  when this script is run, its default download dir is the current
    working directory. this can be changed with the '-D /NEW/DL/PATH'
    flag. NOT IMPLEMENTED YET

*  if you are in windows you must put 'youtube-dl.exe' in the same
    directory as this script.

*  sometimes youtube-dl will fail to get mp3 links :(

*  as always with all web scraping tools, this could become obsolete or
    broken if the bandcamp site changes.
 
*  nothing can be done about the slow download speed :(

*  KEEP IN MIND: IF YOU LIKE INDEPENDENT MUSIC/ARTISTS/SCENES/LABELS 
    YOU SHOULD SUPPORT THESE GROUPS SO THEY KEEP PRODUCING THE STUFF YOU
    LIKE. IF YOU HAVE NICHE INTERESTS; IT IS YOUR OBLIGATION TO SUPPORT
    THESE ARTISTS. 

* this early version is MESSY. cleanup and bug-fixes will come in time.

* all files are streaming quality (128kbps mp3). if you want higher
   quality you will have to pay for them or figure out a different way.

* this script makes no attempt to get the "name your price" albums in
   higher quality

* sometimes youtube-dl will fail to download SOME tracks for an album,
   and will then improperly number the tracks it does download. if you
   can try updating your version of youtube-dl and it may be able to
   grab the tracks it previously couldnt. if so, it will redownload the
   tracks you already have but they will be properly numbered this time.
   this means you will have duplicate tracks with different track
   numbers. for now bandcamp-dl makes no to attempt to clean up these
   misnumbered tracks. in the future there may be a new function added
   to properly pick out tracks from an album page instead of relying on
   youtube-dl and its incremental numbering. TODO.
